package com.itheima.web;

import com.itheima.dto.SetmealDto;
import com.itheima.entity.PageReq;
import com.itheima.entity.Result;
import com.itheima.service.SetmealService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private SetmealService setmealService;

    @PostMapping("/save")
    public Result save(@RequestBody SetmealDto setmealDto){
        return new Result(setmealService.saveSetmeal(setmealDto));
    }

    @GetMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable("id") Long id){
        return new Result(setmealService.deleteById(id));
    }

    @PostMapping("/findByPage")
    public Result findByPage(@RequestBody PageReq req){
        return new Result(setmealService.findByPage(req));
    }

    @GetMapping("/getSetmealPieData")
    public Result getSetmealPieData(){
        return new Result(setmealService.getSetmealPieData());
    }

}
